// miniprogram/pages/huanjing/huangjing.js
const App = getApp();
Page({
  fanhui: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  translateMarker: function () {
    this.mapCtx.translateMarker({
      markerId: 2,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.383302,
        longitude: 113.447399,
      },
      animationEnd() {
        console.log('animation end')
      }
    })
  },
  /**
   * 页面的初始数据
   */
  data: {
    latitude: 23.383159,
    longitude: 113.447332,
    markers: [{
        id: 1,
        latitude: 23.381069,
        longitude: 113.446395,
        name: '教学楼'
      },
      //   {
      //     id: 2,
      //     latitude: 23.380735,
      //     longitude: 113.445524,
      //     name: '西门广场'
      //   },
      //   {
      //     id: 3,
      //     latitude: 23.38046,
      //     longitude: 113.444639,
      //     name: '西门'
      //   },
      //   {
      //     id: 4,
      //     latitude: 23.384409,
      //     longitude: 113.447785,
      //     name: '篮球场'
      //   }
      //   ,
      //   {
      //     id: 5,
      //     latitude: 23.381657,
      //     longitude: 133.449153,
      //     name: '宿舍楼'
      //   }
      //   ,
      //   {
      //     id: 6,
      //     latitude: 23.382009,
      //     longitude: 113.449397,
      //     name: '罗马广场'
      //   },
      //   {
      //     id: 7,
      //     latitude: 23.387096,
      //     longitude: 113.447262,
      //     name: '图书馆'
      //   },
      //   {
      //     id: 8,
      //     latitude: 23.38917,
      //     longitude: 113.445581,
      //     name: '北门'
      //   }
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      navH: App.globalData.navHeight
    })
  },
  translateMarker: function (res) {
    var that = this
    let latitude = 23.38917
    let longitude = 113.445581
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: latitude,
        longitude: longitude
      },
      success() {
        that.setData({
          latitude: latitude,
          longitude: longitude,
        })
      }
    })
    this.setData({
      latitude,
      longitude
    })
  },
  translateMarkerr: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.387096,
        longitude: 113.447262,
      },
      animationEnd() {
        // console.log('animation end')
      }
    })
    this.setData({
      latitude: 23.387096,
      longitude: 113.447262,
    })
  },
  translateMarkerrr: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.382009,
        longitude: 113.449397,
      },
      animationEnd() {
        // console.log('animation end')
      }
    })
    this.setData({
      latitude: 23.382009,
        longitude: 113.449397,
    })
  },
  translateMarkerrrr: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.383159,
        longitude: 113.447332,
      },
      animationEnd() {
        // console.log('animation end')
      }
    })
    this.setData({
      latitude: 23.383159,
      longitude: 113.447332,
    })
  },
  translateMarkerrrrr: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.384409,
        longitude: 113.447785,
      },
      animationEnd() {
        // console.log('animation end')
      }
    })
    this.setData({
      latitude: 23.384409,
      longitude: 113.447785,
    })
  },
  translateMarkerrrrrr: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.381657,
        longitude: 113.449153,
      },
      animationEnd() {
        // console.log('animation end')
      }
    })
    this.setData({
      latitude: 23.381657,
      longitude: 113.449153,
    })
  },
  translateMarkerrrrrrr: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.380735,
        longitude: 113.445524,
      },
      animationEnd() {
        // console.log('animation end')
      }
    })
    this.setData({
      latitude: 23.380735,
      longitude: 113.445524,
    })
  },
  translateMarkerrrrrrrr: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.38046,
        longitude: 113.444639,
      },
      animationEnd() {
        // console.log('animation end')
      }
    })
    this.setData({
      latitude: 23.38046,
      longitude: 113.444639,
    })
  },
  translateMarkerrrrrrrrr: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.381069,
        longitude: 113.446395,
      },
      animationEnd() {
        // console.log('animation end')
      }
    })
    this.setData({
      latitude: 23.381069,
      longitude: 113.446395,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.mapCtx = wx.createMapContext('myMap')
  },
  getCenterLocation: function () {
    this.mapCtx.getCenterLocation({
      success: function (res) {
        console.log(res.longitude)
        console.log(res.latitude)
      }
    })
  },
  moveToLocation: function () {
    this.mapCtx.moveToLocation()
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})